<!DOCTYPE html>
<html lang="en">

  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>可选链式调用</title>
  </head>

  <body>
    <script>
      const flower = {
        colors: {
          red: true
        }
      }
      console.log(flower.colors.red) // 正常运行
      // console.log(flower.species.lily) // 抛出错误：TypeError: Cannot read property 'lily' of undefined 
      console.log(flower.species ?. lily) // 输出 undefined
    </script>
  </body>

</html>
